<?php
/*
 Gets the html table to manage people.
 */
function get_dropdown_list_user_type($dropdown_data) {

	$CI = &get_instance();
	$option_select_list = '';

	foreach ($dropdown_data->result() as $option) {
		$option_select_list .= get_option_data_row_user_type($option);
	}

	if ($dropdown_data -> num_rows() == 0) {
		$option_select_list .= "";
	}

	return $option_select_list;

}

function get_option_data_row_user_type($option) {
	$CI = &get_instance();
	$controller_name = strtolower(get_class($CI));
	$option_data_row = '';
	$option_data_row .= "<option value='" . $option -> user_group_id . "'>" . $option -> name . "</option>";
	return $option_data_row;
}

/*
 Gets user dropdown selected.
 */
function get_dropdown_list_user_type_select($dropdown_data, $group_id) {

	$CI = &get_instance();
	$option_select_list = '';

	foreach ($dropdown_data->result() as $option) {
		$option_select_list .= get_option_data_row_user_type_select($option, $group_id);
	}

	if ($dropdown_data -> num_rows() == 0) {
		$option_select_list .= "";
	}

	return $option_select_list;

}

function get_option_data_row_user_type_select($option, $group_id) {
	$CI = &get_instance();
	$controller_name = strtolower(get_class($CI));
	$option_data_row = '';
	if ($option -> user_group_id == $group_id) {
		$option_data_row .= "<option value='" . $option -> user_group_id . "' selected>" . $option -> name . "</option>";
	} else {
		$option_data_row .= "<option value='" . $option -> user_group_id . "'>" . $option -> name . "</option>";
	}

	return $option_data_row;
}

// get dropdown tags

/*
 Gets the html table to manage people.
 */
function get_dropdown_tags($dropdown_data) {

	$CI = &get_instance();
	$option_select_list = '';

	foreach ($dropdown_data->result() as $option) {
		$option_select_list .= get_option_data_row_tag($option);
	}

	if ($dropdown_data -> num_rows() == 0) {
		$option_select_list .= "";
	}

	return $option_select_list;

}

function get_option_data_row_tag($option) {
	$CI = &get_instance();
	$controller_name = strtolower(get_class($CI));
	$option_data_row = '';
	$option_data_row .= "<option value='" . $option -> tag_id . "'>" . $option -> name . "</option>";
	return $option_data_row;
}

// get dropdown selected

function get_dropdown_tags_select($dropdown_data, $tag_id) {

	$CI = &get_instance();
	$option_select_list = '';

	foreach ($dropdown_data->result() as $option) {
		$option_select_list .= get_option_data_row_tag_select($option, $tag_id);
	}

	if ($dropdown_data -> num_rows() == 0) {
		$option_select_list .= "";
	}

	return $option_select_list;

}

function get_option_data_row_tag_select($option, $tag_id) {
	$CI = &get_instance();
	$controller_name = strtolower(get_class($CI));
	$option_data_row = '';
	if ($option -> tag_id == $tag_id) {
		$option_data_row .= "<option value='" . $option -> tag_id . "' selected>" . $option -> name . "</option>";
	} else {
		$option_data_row .= "<option value='" . $option -> tag_id . "'>" . $option -> name . "</option>";
	}

	return $option_data_row;
}
